package com.linwancun.lwcyback.controller;

import com.linwancun.lwcyback.model.Manager;
import com.linwancun.lwcyback.util.JsonTransformation;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@EnableAutoConfiguration
public class TestController {
    @PostMapping("/123/test")
    @ResponseBody
    public String returntestbywhat(@RequestBody String str) {
        System.out.println(str);
        Manager manager = JsonTransformation.jsonToObject(str, new Manager().getClass());
//        Manager manager = new Manager();
        manager.setManageraccountnumber("asdasd");
        return JsonTransformation.objectToJson(manager);
    }

    @PostMapping("/123/testa")
    public String array(@RequestBody String str) {
        System.out.println(str);
        List<Manager> list = JsonTransformation.jsonToList(str, Manager.class);
        Manager manager = list.get(0);
        manager.setManageraccountnumber("asdasd");
        return JsonTransformation.objectToJson(manager);
    }
}
